package constructor;

public class Point {
	
	int x;
	int y;
	
	// 1.创建一个无参构造,默认x和y都赋值为0
	Point () {
		x = 0;
		y = 0;
	}
	// 2.创建一个只给x赋值的构造，y使用默认值0
	Point (int x2){
		x = x2;
		y = 0;
	}
	// 3.创建一个分别给x,y赋值的构造
	Point (int x2,int y2){
		x = x2;
		y = y2;
	}
	
	public static void main(String[] args) {
		//4.分别调用三个构造创建对象，并输出他们的x和y值
		Point p1 = new Point();
		Point p2 = new Point(10);
		Point p3 = new Point(10,20);
		System.out.println("[" + p1.x +"," + p1.y + "]");
		System.out.println("[" + p2.x +"," + p2.y + "]");
		System.out.println("[" + p3.x +"," + p3.y + "]");
	}
}
